//
//  SCDictionary.swift
//  SwiftCommon
//
//  Created by lijl on 15/7/23.
//  Copyright (c) 2015年 lijialong. All rights reserved.
//

import Foundation

// MARK: - NSDictionary
extension NSDictionary {
    
    /**
    把一个字典类型的数据，转换为url中参数字符串
    
    :returns: <#return value description#>
    */
    func toUrlString()->String{
        
        var str:String = ""
        for (key,value) in self{
            str += ("\(key)=\(value)&")
        }
        
        str = str.subString(str.length - 1)
        return str
    }
    
    /**
    转换为Swift中的Dictionary类型
    
    :returns: <#return value description#>
    */
    func toDictionary()->[String:AnyObject]{
        return self.copy() as! [String:AnyObject]
    }
    
    /**
    转换为可以编辑的字典
    
    :returns: 返回可以编辑的NSMutableDictionary
    */
    func toMutableDictionary()->NSMutableDictionary{
        return NSMutableDictionary(dictionary: self)
    }
    
}